/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.incad.psh.oai_solr;

/**
 *
 * @author Administrator
 */
public class ProgramArguments {

    public String dir = null;
    public String saveDir = null;
    public String dest = null;
    public String xsl = null;
    public String orig = null;
    public String q = null;
    public int start = 0; 
    public String set;
    public String metadataPrefix;
    public String recordId;
    public String from;
    public String until;
    
    public int startNum = 1;
    public int endNum = 1;
    boolean clear;

    public ProgramArguments() {
    }

    public Boolean parse(String[] args) {
        try {
            int total = args.length;
            int i = 0;
            while (i < total) {
                if (args[i].equalsIgnoreCase("-dir")) {
                    i++;
                    dir = args[i];
                } else if (args[i].equalsIgnoreCase("-saveDir")) {
                    i++;
                    saveDir = args[i];
                } else if (args[i].equalsIgnoreCase("-dest")) {
                    i++;
                    dest = args[i];
                } else if (args[i].equalsIgnoreCase("-clear")) {
                    clear = true;
                } else if (args[i].equalsIgnoreCase("-xsl")) {
                    i++;
                    xsl = args[i];
                } else if (args[i].equalsIgnoreCase("-orig")) {
                    i++;
                    orig = args[i];
                } else if (args[i].equalsIgnoreCase("-set")) {
                    i++;
                    set = args[i];
                } else if (args[i].equalsIgnoreCase("-metadataPrefix")) {
                    i++;
                    metadataPrefix = args[i];
                } else if (args[i].equalsIgnoreCase("-from")) {
                    i++;
                    from = args[i];
                } else if (args[i].equalsIgnoreCase("-until")) {
                    i++;
                    until = args[i];
                } else if (args[i].equalsIgnoreCase("-recordId")) {
                    i++;
                    recordId = args[i];
                } else if (args[i].equalsIgnoreCase("-start")) {
                    i++;
                    start = Integer.parseInt(args[i]);
                } else if (args[i].equalsIgnoreCase("-startNum")) {
                    i++;
                    startNum = Integer.parseInt(args[i]);
                } else if (args[i].equalsIgnoreCase("-endNum")) {
                    i++;
                    endNum = Integer.parseInt(args[i]);
                }else if (args[i].equalsIgnoreCase("-q")) {
                    i++;
                    q = args[i];
                }

                i++;
            }
            return true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
}
